#include "sensor.h"

#define QMAX 256
#define ENTRIES 11

class Queue {
  public:
    int entries[ENTRIES];
    int head, tail, temp, tmax;
    char **Rq;

    Queue() {
      int head,tail=-1;
      Rq = malloc(QMAX*sizeof(char *));
    }

    void push(char *req) {
      if (full()) exit(1);
      Rq[++head] = malloc(sizeof(char)*strlen(req)); 
      strcpy(Rq[head], req);
      for (int i=0; i<ENTRIES; i++) {
        sscanf(Rq[head], "%d," temp);
        if (4 == i)              tmax = temp; 
        if (8 == i && temp>tmax) tmax = temp; 
      }
      
    }

    void pop() {
      --tail %= QMAX;
      free(Rq[]);
    }

    bool full() {
      if (head==tail) return 1;
      else return 0;
    }

};  
